//文件名：APP_MQTT
//功能：mqtt相关的函数实现
//创建时间：2023年02月06日
//作者：dowson
//email：dowson.tseng@gmail.com
#ifndef __APP_MQTT_H__
#define __APP_MQTT_H__

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

#define MQTT_SUB_BUFFER_NODE_SIZE 1024
#define MQTT_SUB_BUFFER_SIZE 4
#define MQTT_TOPIC_LEN_MAX 128
//MQTT 数据缓存
typedef struct struct_MqttSubMsgBuffer
{
	uint8_t Qos;
	uint8_t dup;
	uint8_t retained;
    uint8_t data[MQTT_SUB_BUFFER_NODE_SIZE];
	uint8_t topic[MQTT_TOPIC_LEN_MAX];
	uint8_t mqIndex;
	uint16_t dataLen; 
}tMqttSubMsgBuffer;


typedef struct struct_MqttSubStruct
{
    uint8_t dataBuff[512];
}tMqttSubStruct;


enum {MQTT_INDEX1=1,MQTT_INDEX2,MQTT_INDEX3,MQTT_INDEX4,MQTT_INDEX5};


void MqttPartInit(void);
void MqttSubDataCallBack(char *dataBuf, uint32_t dataLen);
void MQTTInitTask(void);
void Mqtt1SubTask(void);
void MqttDataPublish(void);
void MqttDisconnectCheck(uint8_t* buffData);
void MqttConnectStateMark(uint8_t state);
uint8_t MqttConnectStateGet(void);
int8_t String2Ascii(uint8_t* srcString,uint16_t stringLen,uint8_t* dstBuff,uint16_t buffLen);

void MqttSbuIqr(uint8_t* data,uint16_t dataLen);
void Mqtt1SubCallBack(uint8_t* data);


#endif
